package com.atguigu.gulimall.thirdpart.controller.wechat.service;

import com.atguigu.gulimall.thirdpart.controller.wechat.entity.UserAccessToken;
import com.atguigu.gulimall.thirdpart.controller.wechat.entity.WeChatUserInfo;

/**
 * 微信网页授权
 *
 * @author zhangxueyou
 * @date 2020/10/2-20:55
 */

public interface AuthorizeService {

    /**
     * 获取  code(不弹出授权页面)的url
     * @param appid
     * @param redirectUri
     * @param state
     * @return
     */
    String genSnsapiBaseUrl(String appid, String redirectUri, String state);

    /**
     * 获取code(弹出授权页面)的url
     * @param appId
     * @param redirectUri
     * @param state
     * @return
     */
    String genSnsapiUserInfo(String appId, String redirectUri, String state);

    /**
     * 根据code获取access_token等信息
     * @param appId
     * @param appsecret
     * @param code
     * @return
     */
     UserAccessToken getUserAcsTokenByCode(String appId,String appsecret,String code);

    /**
     * 刷新access_token
     * @param appid
     * @param grant_type
     * @param refresh_token
     * @return
     */
    UserAccessToken refreshUserAcsToken(String appid, String grant_type, String refresh_token);

    /**
     * 拉取用户信息(授权页面时)
     * @param accesstoken
     * @param openid
     * @param lang
     * @return
     */
    WeChatUserInfo getWeChatUnSubscribeUserInfo(String accesstoken ,String openid);

    /**
     * 拉取已经关注公众号的用户的信息
     * @param accesstoken
     * @param openid
     * @param lang
     * @return
     */
    WeChatUserInfo getWeChatSubscribeUserInfo(String accesstoken ,String openid);


    /**
     * 检验授权凭证（access_token）是否有效
     * 正确返回：{ "errcode":0,"errmsg":"ok"}
     * 错误返回：{ "errcode":40003,"errmsg":"invalid openid"}
     * @param accesstoken
     * @param openid
     * @return
     */
    UserAccessToken checkUserToken(String accesstoken,String openid);
}
